package com.mccken.demo.classload;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;

import cn.hutool.core.compiler.CompilerUtil;
import lombok.SneakyThrows;

/**
 * @program: mccken-collect
 * @description:
 * @author: mccken
 * @create: 2023-11-23 14:55
 **/
public class McckenCompiler {
	
	@SneakyThrows
	public static void main(String[] args) {
		run();

	}

	public static void run() throws IOException {
		boolean compile = CompilerUtil.compile("/Users/mccken/Downloads/temp/Demo.java");
		
		if (compile) {
			Files.deleteIfExists(Paths.get("/Users/mccken/Downloads/temp/compiler/com.mccken.demo.classload.Demo.class"));
			Files.move(Paths.get("/Users/mccken/Downloads/temp/Demo.class"),
					Paths.get("/Users/mccken/Downloads/temp/compiler/com.mccken.demo.classload.Demo.class"));
			
			System.out.println("编译成功");
		} else {
			System.out.println("编译失败");
		}
	}

}
